package com.tcfvic.client.panels.widgets.widgetcontents;

import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ListBox;
import com.tcfvic.client.pojos.Person;
import com.tcfvic.client.tools.State;

public abstract class AbstractDataEntryWidgets {
	protected Button saveButton = new Button("Save");
	protected String idDelimiter = "-";

	public ListBox getStatesListBox() {
		final ListBox dropBox = new ListBox(false);

		dropBox.addItem("");
		for (State state : State.values()) {
			dropBox.addItem(state.getState());
		}
		return dropBox;
	}

	public void setSaveClickHandler(ClickHandler clickHandler) {
		// Add a handler to close the DialogBox
		saveButton.addClickHandler(clickHandler);
	}

	public Button getSaveButton() {
		return saveButton;
	}

	public int getListIndexBasedOnId(ListBox list, String id) {
		for (int i = 0; i < list.getItemCount(); i++) {
			if (list.getValue(i).equals(id)) {
				return i;
			}
		}
		return 0;
	}

	public void onSave(Person person) {

	}
}
